class filesystem :
    def __init__ ( self , mediator , builtins , os ) :
        self . _mediator = mediator
        self . _builtins = builtins
        self . _os = os
    def create_file ( self , name , contents ) :
        file = self . _builtins . open ( name , 'w' )
        file . writelines ( [ line + '\n' for line in contents ] )
        file . close ( )
    def delete_file ( self , name ) :
        self . _os . remove ( name )
    def read_file_request ( self , name ) :
        file = self . _builtins . open ( name , 'r' )
        contents = [ ]
        for line in file . readlines ( ) :
            if line . endswith ( '\n' ) :
                contents += [ line [ : -1 ] ]
            else :
                contents += [ line ]
        file . close ( )
        self . _mediator . read_file_reply ( name , contents )
    def list_files_request ( self ) :
        self . _mediator . list_files_reply ( list ( self . _os . listdir ( '.' ) ) )
